﻿@{
    Layout = null;
    var returnUrl = Request.QueryString["returnUrl"];
    if (!string.IsNullOrEmpty(returnUrl)) {
        returnUrl = System.Web.HttpUtility.UrlDecode(returnUrl);
    }
}
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>登陆</title>
    <meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0,maximum-scale=1.0, user-scalable=no" />

    <link href="~/Content/css/base.css" rel="stylesheet" />
    <link rel="stylesheet" href="~/Content/css/tuoken.css" />
    <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    <script type="text/javascript" src="~/Content/js/base.js"></script>
    <script src="~/Content/js/layer/1.9.3/layer.js"></script>
</head>
<body>
    <div class="aboutwhite">
        <div class="autoinfoct">
            <a href="javascript:history.go(-1);" class="backbtn">
                <span class="back"></span>
            </a>
            <div class="login">

                <div class="logininput">
                    <input class="name" type="text" id="phone" placeholder="输入手机号">
                </div>
                <div class="logininput loginiyzm">
                    <input class="nickname" type="text" id="yzm" placeholder="短信验证码">
                    <input type="button" class="yzm" value="获取验证码" />
                    <input type="hidden" name="token" value="" id="token" />
                </div>

                <input type="button" class="autobtn" id="autobtn" value="立即开启" onclick="submit()" disabled="disabled">
                <p>开启即表示同意<a href="~/Agreement/UserAgreement.html">《用户服务协议》</a></p>

            </div>
        </div>
    </div>
    <div id="popup"></div>
    <script src="https://cdn.dingxiang-inc.com/ctu-group/captcha-ui/index.js"></script>
    <script type="text/javascript">
        var myCaptcha;
        $(function () {
            myCaptcha = _dx.Captcha(document.getElementById('popup'), {
                appId: 'd857f517ea59f9c229a76b88aa938719',
                style: 'popup',
                success: function (token) {
                    $("#token").val(token);
                    myCaptcha.hide();
                    sendsms();
                }
            })
        });
        //var countdown = 60;
        //var obj = $(".yzm");
        function isPoneAvailable(poneInput) {
            var myreg = /^[1][3,4,5,7,8][0-9]{9}$/;
            if (!myreg.test(poneInput)) {
                return false;
            } else {
                return true;
            }
        }
        var fn = function sendsms() {

            $.ajax({
                //几个参数需要注意一下
                type: "POST",//方法类型
                dataType: "json",//预期服务器返回的数据类型
                url: "/Home/GetCode",//url
                data: { Mobile: $("#phone").val(), code: $("#token").val()},
                success: function (result) {
                    if (result.result_code == 1000) {
                        layer.msg(result.result_msg);
                        new invokeSettime(".yzm");
                    }
                    else {
                        layer.msg(result.result_msg);
                        new invokeFn(".yzm", fn);
                    }
                },
                error: function () {
                    layer.msg("异常！");
                    new invokeFn(".yzm", fn);
                }
            });

            //settime(obj);

        }
        //function settime(obj) {

        //    if (countdown == 0) {
        //        obj.removeAttribute("disabled");
        //        obj.value = "获取验证码";
        //        countdown = 60;
        //        return;
        //    } else {
        //        obj.attr("disabled", true);
        //        obj.value = "重新发送(" + countdown + ")";
        //        countdown--;
        //    }

        //    setTimeout(function () { settime(obj) }, 1000)
        //}
        var fn = function () {
            if ($("#phone").val() == "") {
                layer.msg("手机号码不能为空"); return;
            }
            //if (isPoneAvailable($("#phone").val()) == false) {
            //    layer.msg("手机号码不正确"); return;
            //}
            $(".yzm").unbind("click");
            myCaptcha.reload();
            myCaptcha.show()
        }
        $(".yzm").click(fn);
        function invokeSettime(obj) {
            var countdown = 60;
            settime(obj);
            function settime(obj) {
                if (countdown == 0) {
                    $(obj).click(fn);
                    $(obj).val("获取验证码");
                    countdown = 60;
                    return;
                } else {
                    $(obj).unbind("click");
                    $(obj).val("(" + countdown + ") s ");
                    countdown--;
                }
                setTimeout(function () {
                    settime(obj)
                }, 1000)
            }
        }

        function invokeFn(obj, fn) {
            $(obj).click(fn);
        }
        $(".logininput input").keyup(function () {

            var phone = $("#phone").val();
            var yzm = $("#yzm").val();

            if (phone != "" && yzm != "") {
                $("#autobtn").attr("disabled", false);
                $('#autobtn').addClass('on');
            } else {
                $("#autobtn").attr("disabled", true);

                $('#autobtn').removeClass('on');
            }
        })

        function submit() {
            if ($("#phone").val() == "") {
                layer.msg("手机号码不能为空");
            } else if ($("#yzm").val() == "") {
                layer.msg("请输入验证码");
            }
            else {
                $.ajax({
                    //几个参数需要注意一下
                    type: "POST",//方法类型
                    dataType: "json",//预期服务器返回的数据类型
                    url: "/Home/LoginPost",//url
                    data: { Mobile: $("#phone").val(), Vcode: $("#yzm").val() },
                    success: function (result) {
                        if (result.result_code == 1000) {
                            layer.msg("登录成功");
                            window.location.href = '@Html.Raw((!string.IsNullOrEmpty(returnUrl) ? returnUrl : "/home/index"))';
                        } else {
                            layer.msg(result.result_msg);
                        }
                    },
                    error: function () {
                        layer.msg("异常！");
                    }
                });
            }
        }


    </script>
    @*<script type="text/javascript">
            var countdown = 60;
            function isPoneAvailable(poneInput) {
                var myreg = /^[1][3,4,5,7,8][0-9]{9}$/;
                if (!myreg.test(poneInput)) {
                    return false;
                } else {
                    return true;
                }
            }
            function sendsms() {
                if ($("#phone").val() == "") {
                    layer.msg("手机号码不能为空");
                } else if (isPoneAvailable($("#phone").val()) == false) {
                    layer.msg("手机号码不正确");
                } else {
                    $.ajax({
                        //几个参数需要注意一下
                        type: "POST",//方法类型
                        dataType: "json",//预期服务器返回的数据类型
                        url: "/Home/GetCode",//url
                        data: { Mobile: $("#phone").val() },
                        success: function (result) {
                            layer.msg(result.message);
                        },
                        error: function () {
                            layer.msg("异常！");
                        }
                    });
                }
                var obj = $(".yzm");
                settime(obj);

            }
            function settime(obj) {

                if (countdown == 0) {
                    obj.removeAttribute("disabled");
                    obj.value = "获取验证码";
                    countdown = 60;
                    return;
                } else {
                    obj.setAttribute("disabled", true);
                    obj.value = "重新发送(" + countdown + ")";
                    countdown--;
                }

                setTimeout(function () { settime(obj) }, 1000)
            }

            $(".logininput input").keyup(function () {

                var phone = $("#phone").val();
                var yzm = $("#yzm").val();

                if (phone != "" && yzm != "") {
                    $("#autobtn").attr("disabled", false);
                    $('#autobtn').addClass('on');
                } else {
                    $("#autobtn").attr("disabled", true);

                    $('#autobtn').removeClass('on');
                }
            })

            function submit() {
                if ($("#phone").val() == "") {
                    layer.msg("手机号码不能为空");
                } else if ($("#yzm").val() == "") {
                    layer.msg("请输入验证码");
                }
                else {
                    $.ajax({
                        //几个参数需要注意一下
                        type: "POST",//方法类型
                        dataType: "json",//预期服务器返回的数据类型
                        url: "/Home/LoginPost",//url
                        data: { Mobile: $("#phone").val(), Vcode: $("#yzm").val() },
                        success: function (result) {
                            if (result.code == 1000) {
                                var obj = JSON.parse(result.data.Setting);

                                if (obj.auth_info.id_card == null || obj.auth_info.id_card == "") {
                                    window.location.href = "/User/Authentication";
                                }

                            } else {
                                layer.msg(result.msg);
                            }
                        },
                        error: function () {
                            layer.msg("异常！");
                        }
                    });
                }
            }


        </script>*@
</body>
</html>